package com.yoomiito.app.utils;

import com.google.android.material.tabs.TabLayout;

/**
 * com.google.android.material.tabs.TabLayout 不再需要
 */

@Deprecated
public class TabLayoutUtils {

    public static void setIndicator(TabLayout tabs, int leftDip, int rightDip) {
//        Class<?> tabLayout = tabs.getClass();
//        Field tabStrip = null;
//        try {
        //在androidX中会报空指针 待定
////            tabStrip = tabLayout.getDeclaredField("mTabStrip");
////            if (tabStrip==null){
//                tabStrip = tabLayout.getDeclaredField("slidingTabIndicator");
//                L.i("Tablayout0: "+tabStrip);
////            }
//        } catch (NoSuchFieldException e) {
//            e.printStackTrace();
//        }
//        L.i("Tablayout1: "+tabStrip);
//        tabStrip.setAccessible(true);
//        LinearLayout llTab = null;
//        try {
//            llTab = (LinearLayout) tabStrip.get(tabs);
//        } catch (IllegalAccessException e) {
//            e.printStackTrace();
//        }
//
//        int left = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, leftDip, Resources.getSystem().getDisplayMetrics());
//        int bg_green_right_2 = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rightDip, Resources.getSystem().getDisplayMetrics());
//
//        for (int i = 0; i < llTab.getChildCount(); i++) {
//            View child = llTab.getChildAt(i);
//            child.setPadding(0, 0, 0, 0);
//            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
//            params.leftMargin = left;
//            params.rightMargin = bg_green_right_2;
//            child.setLayoutParams(params);
//            child.invalidate();
//        }
    }
}
